package com.ziroom.crm.mq.core.node;

import java.util.concurrent.atomic.LongAdder;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author WeiShaoying
 * @version 1.0
 * @date Created in 2020年08月31日 15:59
 * @since 1.0
 */
public class StatisticNode implements Node {

    /**
     * 成功个数
     */
    private final LongAdder totalSendSuccess = new LongAdder();

    /**
     * 失败个数
     */
    private final LongAdder totalSendException = new LongAdder();

    /**
     * 重试成功个数
     */
    private final LongAdder totalReSendSuccess = new LongAdder();

    /**
     * 重试失败个数
     */
    private final LongAdder totalReSendException = new LongAdder();

    /**
     * 消费成功个数
     */
    private final LongAdder totalConsumeSuccess = new LongAdder();

    /**
     * 消费失败个数
     */
    private final LongAdder totalConsumeException = new LongAdder();

    /**
     * 消费重试成功个数
     */
    private final LongAdder totalReConsumeSuccess = new LongAdder();

    /**
     * 消费重试失败个数
     */
    private final LongAdder totalReConsumeException = new LongAdder();


    @Override
    public long totalSend() {
        return totalSendSuccess.longValue() + totalSendException.longValue();
    }

    @Override
    public long totalSendSuccess() {
        return totalSendSuccess.longValue();
    }

    @Override
    public long totalSendException() {
        return totalSendException.longValue();
    }

    @Override
    public void incSendSuccess() {
        totalSendSuccess.increment();
    }

    @Override
    public void incSendException() {
        totalSendException.increment();
    }

    @Override
    public long totalReSendSuccess() {
        return totalReSendSuccess.longValue();
    }

    @Override
    public long totalReSendException() {
        return totalReSendException.longValue();
    }

    @Override
    public void incReSendSuccess() {
        totalReSendSuccess.increment();
        totalSendSuccess.increment();
    }

    @Override
    public void incReSendException() {
        totalReSendException.increment();
        totalSendException.increment();
    }

    @Override
    public long totalConsume() {
        return totalConsumeSuccess.longValue() + totalConsumeException.longValue();
    }

    @Override
    public long totalConsumeSuccess() {
        return totalConsumeSuccess.longValue();
    }

    @Override
    public long totalConsumeException() {
        return totalConsumeException.longValue();
    }

    @Override
    public long totalReConsumeSuccess() {
        return totalReConsumeSuccess.longValue();
    }

    @Override
    public long totalReConsumeException() {
        return totalReConsumeException.longValue();
    }

    @Override
    public void incConsumeSuccess() {
        totalConsumeSuccess.increment();
    }

    @Override
    public void incConsumeException() {
        totalConsumeException.increment();
    }

    @Override
    public void incReConsumeSuccess() {
        totalConsumeSuccess.increment();
        totalReConsumeSuccess.increment();
    }

    @Override
    public void incReConsumeException() {
        totalConsumeException.increment();
        totalReConsumeException.increment();
    }
}
